package com.bw.yk02.util;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

public class MyKeywordBYIK {

    public List<String> getKeywords(String str)
    {
        List<String> list=new ArrayList<String>();
        if(str!=null)
        {
            StringReader sr=new StringReader(str);
            IKSegmenter ikSegmenter=new IKSegmenter(sr,false);

            try{
                Lexeme le=ikSegmenter.next();
                while (le!=null)
                {
                    String word=le.getLexemeText();
                    list.add(word);

                    le=ikSegmenter.next();
                }

            }catch (Exception e)
            {
                e.printStackTrace();
            }

        }
        return list;
    }
}
